package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /**
     * 批量保存套餐和菜品的关联关系
     * @param setmealDish
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into setmeal_dish (setmeal_id, dish_id, name, copies, price) " +
            "values (#{setmealId}, #{dishId}, #{name}, #{copies}, #{price})")
    void save(SetmealDish setmealDish);

    /**
     * 根据套餐id删除套餐菜品关系
     * @param id
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteBySetmealId(Long id);

    /**
     * 根据套餐id查询套餐菜品关系
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getBySetmealId(Long id);
}
